<?php
class site_cityControl extends skymvc{
	
	public function __construct(){
		parent::__construct();
	}
	
	public function onDefault(){
		$data=M('site_city')->children(0);
			 
			
			if($data){
				foreach($data as $k=>$v){
					 
					if($v['child']){
						foreach($v['child'] as $kk=>$vv){
							 
							$v['child'][$kk]=$vv;
						}
					}
					$data[$k]=$v;
				}
			}
			$ndata=array(
				"data"=>$data,
				 
			);
			if(get_post('ajax')){
				$this->goAll("success",0,$ndata);
			}
			$this->smarty->assign($ndata);
		$this->smarty->display("site_city/index.html");
	}
	
	public function onChild(){
		$pid=get('pid','i');
		if($pid>0){
			$data=M("site_city")->select(array(
				"where"=>"pid=".$pid,
				"order"=>"orderindex ASC"
			));
			$this->goAll("success",0,$data);
		}
		$this->goAll("无下级",1);
	}
		
}

?>